package imse.team1.transportationorder.googlemapsapi;

import java.util.ArrayList;
import java.util.List;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class CustomizedSAXHandler1 extends DefaultHandler{
	boolean dname = false;
	boolean dtname = false;
	String distance = new String();  
	
	
	public void startElement(String uri, String localName,String qName, 
                Attributes attributes) throws SAXException {
         
		 // System.out.println("Start Element :" + qName);
 
		if (qName.equalsIgnoreCase("distance")) {
			dname = true;
		}
 
		if (qName.equalsIgnoreCase("text") && dname == true) {
			dtname = true;
		}
	}
 
	public void endElement(String uri, String localName,
		String qName) throws SAXException {
 
	    //	System.out.println("End Element :" + qName);
 
	}
 
	public void characters(char ch[], int start, int length) throws SAXException {
		if (dtname && dname) {
			// System.out.println("Distance : " + new String(ch, start, length));
			distance = new String(ch, start, length);
			dtname = false;
			dname = false;
		}
 	}
	
	public String returnDistance() {
		return distance;
	}
 
}
